<? session_start();

include 'functions.php';
include 'constants.php';

if($_GET['logout']){
	$_SESSION['employee_id'] = null;
}
if($_POST['id']){
	$db=new SQLiteDatabase("db/mandi");

	$result=$db->query("select * from employees where status = \"ACTIVE\" AND id = ".$_POST['id']);
	if($row=$result->fetch(SQLITE_ASSOC)){
		$_SESSION['employee_id'] = $row['id'];
		$_SESSION['employee_name'] = $row['name'];
	}
}


?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Mandi Login</title>
</head>

<body>
<?
	if(!$_SESSION['employee_id']){
		//logged out
		?>
		<form action="" method="POST">
		<input type="text" name="id"></input>
		<input type="submit"></input>
		</form>
		<?
	}else{
		//logged in
		include 'navbar.php';
?>		<div class="body-content">
			<h2>Welcome to the Stanford Mandi.</h2>
			<div>Logged in.</div>
		</div>
<?
	}


?>


</body>

</html>